package com.demo.common.core.response;


import com.demo.common.core.constant.CommonConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.lang.NonNull;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;


@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PageResponse<T> implements Serializable {

    private static final long serialVersionUID = 3148243009239266398L;

    /**
     * 数据
     */
    private List<T> records;

    /**
     * 总条数
     */
    private Long total;


    public static <T> PageResponse<T> empty(){
        return new PageResponse<>(Collections.emptyList(), CommonConstants.LONG_ZERO);
    }

    public static <T> PageResponse<T> empty(@NonNull Long total){
        return new PageResponse<>(Collections.emptyList(), total);
    }
}
